只需要提供sipserverIP:SIP账号SIP密码即可实现通信。所有配置请看相关图片比较详细的sip软电话采用的是VAXvoipsdk
Private Const SND_FILENAME = &H20000
Private Const SND_LOOP = &H8
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(lpszName As Any, ByVal hModule As Long, ByVal dwFlags As Long) As Boolean
Private Sub BtnClearLog_Click()
ListStatusLog.Clear
End Sub
Private Sub BtnDialPad0_Click()
EditPhoneNo.Text = EditPhoneNo.Text "0"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "0")
End Sub
Private Sub BtnDialPad1_Click()
EditPhoneNo.Text = EditPhoneNo.Text "1"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "1")
End Sub
Private Sub BtnDialPad2_Click()
EditPhoneNo.Text = EditPhoneNo.Text "2"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "2")
End Sub
Private Sub BtnDialPad3_Click()
EditPhoneNo.Text = EditPhoneNo.Text "3"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "3")
End Sub
Private Sub BtnDialPad4_Click()
EditPhoneNo.Text = EditPhoneNo.Text "4"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "4")
End Sub
Private Sub BtnDialPad5_Click()
EditPhoneNo.Text = EditPhoneNo.Text "5"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "5")
End Sub
Private Sub BtnDialPad6_Click()
EditPhoneNo.Text = EditPhoneNo.Text "6"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "6")
End Sub
Private Sub BtnDialPad7_Click()
EditPhoneNo.Text = EditPhoneNo.Text "7"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "7")
End Sub
Private Sub BtnDialPad8_Click()
EditPhoneNo.Text = EditPhoneNo.Text "8"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "8")
End Sub
Private Sub BtnDialPad9_Click()
EditPhoneNo.Text = EditPhoneNo.Text "9"
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "9")
End Sub
Private Sub BtnDialPadStar_Click()
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "*")
End Sub
Private Sub BtnDialPadNo_Click()
Result = VaxSIPUserAgentOCX.DigitDTMF(ListLines.ListIndex, "#")
End Sub
Private Sub BtnHelpMore_Click()
HelpForm.Show vbModal
End Sub
Private Sub BtnPlayForward_Click()
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveSkipTo(LineNo, VaxSIPUserAgentOCX.PlayWavePosition(LineNo) 2)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnPlayPause_Click()
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.PlayWavePause(LineNo)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnPlayRewind_Click()
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveSkipTo(LineNo, VaxSIPUserAgentOCX.PlayWavePosition(LineNo) - 2)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnPlayStop_Click()
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveStop(LineNo)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnSetPlayFile_Click()
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveOpen(LineNo, EditPlayFileName.Text)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnStartPlay_Click()
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.PlayWaveStart(LineNo, CheckPlayListen.Value)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub BtnTransferCall_Click()
ToURI = "sip:" EditTransferPhoneNo.Text "@" EditSIPProxy.Text
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.TransferCall(LineNo, ToURI)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub CheckAGC_Click()
If CheckAGC.Value = 1 Then
Result = VaxSIPUserAgentOCX.EnableAGC(8000)
If Result = False Then
ErrorMessages
End If
Else
VaxSIPUserAgentOCX.DisableAGC
End If
End Sub
Private Sub CheckMuteMic_Click()
Result = VaxSIPUserAgentOCX.MuteMic(CheckMuteMic.Value)
End Sub
Private Sub CheckPlayRingTone_Click()
If CheckPlayRingTone.Value <> 1 Then
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
End If
End Sub
Private Sub CheckSpkMute_Click()
Dim Result
Result = VaxSIPUserAgentOCX.MuteSpk(CheckSpkMute.Value)
End Sub
Private Sub CheckStartConf_Click()
BusyCount = 0
For LineNo = 0 To 6
If VaxSIPUserAgentOCX.IsLineBusy(LineNo) = True Then
BusyCount = BusyCount 1
End If
Next LineNo
If BusyCount < 2 And CheckStartConf.Value Then
CheckStartConf.Value = False
MsgBox ("Dial/receive more than one calls and then click start conference check box.")
End If
End Sub
Private Sub CheckStartRecording_Click()
If CheckStartRecording.Value = 1 Then
Result = VaxSIPUserAgentOCX.StartRecording(ListLines.ListIndex, 2, True)
If Result = False Then
ErrorMessages
End If
Else
Result = VaxSIPUserAgentOCX.StopRecording(ListLines.ListIndex)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
End Sub
Private Sub SliderMicVol_Click()
' SetMicVolume method requires Volume value from 0 to 255 range '
' but the slider range is 0 to 10, so we multiply the slider value '
' to 25 to get the required value to pass to SetMicVolume method '
Dim Result
Result = VaxSIPUserAgentOCX.SetMicVolume(SliderMicVol.Value * 25)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub SliderSpkVol_Click()
' SetSpkVolume method requires Volume value from 0 to 255 range '
' but the slider range is 0 to 10, so we multiply the slider value '
' to 25 to get the required value to pass to SetSpkVolume method '
Dim Result
Result = VaxSIPUserAgentOCX.SetSpkVolume(SliderSpkVol.Value * 25)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub ErrorMessages()
Dim Error
Error = VaxSIPUserAgentOCX.GetVaxObjectError
If Error = 10 Then
MsgBox ("You are not Online, please click the 'Online' button first.")
End If
If Error = 11 Then
MsgBox ("Cann't open local communication port. Another softphone (x-Ten, x-lite or skype etc) is already running. Please close it first.")
End If
If Error = 12 Then
MsgBox ("License Key is not valid.")
End If
If Error = 13 Then
MsgBox ("Fail to initialize VaxVoIP task window.")
End If
If Error = 14 Then
MsgBox ("Cann't access Input/Mic device or device is already in use.")
End If
If Error = 15 Then
MsgBox ("Cann't access Output/Speaker device or device is already in use.")
End If
If Error = 16 Then
MsgBox ("Input/Mic device is not open.")
End If
If Error = 17 Then
MsgBox ("Output/Speaker device is not open.")
End If
If Error = 18 Then
MsgBox ("Your sound device does not support mic volume.")
End If
If Error = 19 Then
MsgBox ("Your sound device does not support speaker volume.")
End If
If Error = 20 Then
MsgBox ("Recording media initialization fail.")
End If
If Error = 21 Then
MsgBox ("Cann't open the wave file.")
End If
If Error = 22 Then
MsgBox ("Provided SIP URI is not valid.")
End If
If Error = 23 Then
MsgBox ("Codec is not supported.")
End If
If Error = 24 Then
MsgBox ("Error to create SDP (Session Description Protocol) request.")
End If
If Error = 25 Then
MsgBox ("Error to create CONNECTION request. Please check the provided SIP URI is valid.")
End If
If Error = 26 Then
MsgBox ("Error to create REGISTER request. Please check the provided SIP URI is valid.")
End If
If Error = 27 Then
MsgBox ("Error to create UN-REGISTER request. Please check the provided SIP URI is valid.")
End If
If Error = 28 Then
MsgBox ("Error to create DISCONNECT request.")
End If
If Error = 29 Then
MsgBox ("Line No is not valid.")
End If
If Error = 30 Then
MsgBox ("Line is already busy.")
End If
If Error = 31 Then
MsgBox ("Line is not open.")
End If
If Error = 32 Then
MsgBox ("Invalid Call-Id.")
End If
If Error = 33 Then
MsgBox ("Provided value is not valid.")
End If
If Error = 34 Then
MsgBox ("Selected line is not in voice session.")
End If
If Error = 35 Then
MsgBox ("Fail to read wave file.")
End If
If Error = 36 Then
MsgBox ("Fail to write wave file.")
End If
If Error = 37 Then
MsgBox ("Unsupported wave file format.")
End If
End Sub
Private Function InitVaxVoIPObject(ByVal MyIP As String, ByVal FromURI As String) As Boolean
Dim ListenPort As Integer
Dim Result As Boolean
Result = False
ListenPort = 5060
Do While ListenPort < 7000
Result = VaxSIPUserAgentOCX.Initialize(False, MyIP, ListenPort, FromURI, EditOutBoundProxy.Text, EditSIPProxy.Text, EditLoginId.Text, EditLoginPwd.Text, True, 7)
If Result = False Then
If 11 <> VaxSIPUserAgentOCX.GetVaxObjectError() Then
ErrorMessages
Exit Do
End If
Else
Exit Do
End If
ListenPort = ListenPort 1
Loop
If ListenPort >= 7000 Then
MsgBox ("Cann't open SIP communication port.")
Result = False
End If
InitVaxVoIPObject = Result
End Function
Private Function OpenLines(ByVal MyIP As String, ByVal TotalNoOfLine As Integer) As Boolean
Dim ListenPort As Integer
Dim Result As Boolean
Dim ErrorCount As Integer
Result = False
ListenPort = 7000
ErrorCount = 0
For LineNo = 0 To (TotalNoOfLine - 1)
Result = VaxSIPUserAgentOCX.OpenLine(LineNo, False, MyIP, ListenPort)
If Result = False Then
If 11 <> VaxSIPUserAgentOCX.GetVaxObjectError() Then
ErrorMessages
Exit For
Else
ErrorCount = ErrorCount 1
LineNo = LineNo - 1
End If
End If
ListenPort = ListenPort 2 ' It is importent to increament RTP Listen port by 2
If ErrorCount >= (TotalNoOfLine 1000) Then ' If unable to open more than 1000 ports.
MsgBox ("Unable to open RTP communication port.")
Result = False
Exit For
End If
Next LineNo
OpenLines = Result
End Function
Private Sub BtnOnline_Click()
Dim MyIP
Dim FromURI
If BtnOnline.Caption = "Offline" Then
TimerTick.Enabled = False
TimerProgressBar.Enabled = False
SpkProgress.Value = 0
MicProgress.Value = 0
VaxSIPUserAgentOCX.UnInitialize
ComboAudioIn.Clear
ComboAudioOut.Clear
BtnOnline.Caption = "Online"
Exit Sub
End If
If EditLoginId.Text = "" Then
MsgBox ("Please enter the SIP proxy Login Id.")
Exit Sub
End If
If EditSIPProxy.Text = "" Then
MsgBox ("Please enter the SIP proxy address or URI.")
Exit Sub
End If
VaxSIPUserAgentOCX.SetLicenceKey ("TRIAL-LICENSE-KEY")
'****** Constructing SIP From URI for IP Telephony *******
If EditDisplayName = "" Then
FromURI = EditLoginId.Text " <sip:" EditLoginId.Text "@" EditSIPProxy.Text ">"
Else
FromURI = EditDisplayName.Text " <sip:" EditLoginId.Text "@" EditSIPProxy.Text ">"
End If
'********************************************************************
' Listen Port: default SIP port 5060.
' SIP Proxy: SIP Proxy IP or FQDN provided by your service provider.
' OutboundProxy: SIP outbound/NAT proxy IP or FQDN provided by your
' service provider to use SIP phone behind the NAT.
'
'*********************************************************************
MyIP = VaxSIPUserAgentOCX.GetMyIP()
Result = InitVaxVoIPObject(MyIP, FromURI)
If Result = False Then
Exit Sub
End If
Result = OpenLines(MyIP, 7)
If Result = False Then
Exit Sub
End If
If CheckRegisterToProxy.Value = 1 Then
Result = VaxSIPUserAgentOCX.RegisterToProxy(3600)
If Result = False Then
ErrorMessages
Exit Sub
End If
AddToStatusLog ("Registering to SIP Proxy.")
End If
If CheckEchoCancel.Value Then
VaxSIPUserAgentOCX.EnableEchoNoiseCancellation
Else
VaxSIPUserAgentOCX.DisableEchoNoiseCancellation
End If
VaxSIPUserAgentOCX.DeselectAllVoiceCodec
If CheckGSM610.Value Then
VaxSIPUserAgentOCX.SelectVoiceCodec (0)
End If
If CheckiLBC.Value Then
VaxSIPUserAgentOCX.SelectVoiceCodec (1)
End If
If CheckG711A.Value Then
VaxSIPUserAgentOCX.SelectVoiceCodec (2)
End If
If CheckG711U.Value Then
VaxSIPUserAgentOCX.SelectVoiceCodec (3)
End If
VaxSIPUserAgentOCX.EnableKeepAlive (10)
BtnOnline.Caption = "Offline"
UpdateSoundDevices
TimerTick.Enabled = True
TimerProgressBar.Enabled = True
End Sub
Private Sub VaxSIPUserAgentOCX_OnCallTransferAccepted(ByVal LineNo As Long)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Transfer accepted.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnConnecting(ByVal LineNo As Long)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Connecting.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnDisconnectCall(ByVal LineNo As Long)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Hung up.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnDTMFDigit(ByVal LineNo As Long, ByVal Digit As String)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Key-pressed: " Digit)
End Sub
Private Sub VaxSIPUserAgentOCX_OnFailToConnect(ByVal LineNo As Long)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Fail to connect.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnFailToRegister()
AddToStatusLog ("Fail to register.")
End Sub
Private Function FindCallIdFromList(ByVal CallId As String) As Boolean
Dim Result As Boolean
Result = False
For ListIndex = 0 To (ListIncomingCallIds.ListCount - 1)
If UCase(ListIncomingCallIds.List(ListIndex)) = UCase(CallId) Then
Result = True
Exit For
End If
Next ListIndex
FindCallIdFromList = Result
End Function
Private Sub VaxSIPUserAgentOCX_OnGeneralFailureResponse(ByVal LineNo As Long, ByVal StatusCode As Long, ByVal ReasonPhrase As String)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) " Response: " ReasonPhrase)
End Sub
Private Sub VaxSIPUserAgentOCX_OnIncomingCall(ByVal CallId As String, ByVal DisplayName As String, ByVal UserName As String, ByVal FromURI As String, ByVal ToURI As String)
If FindCallIdFromList(CallId) = False Then
ListIncomingCallIds.AddItem (CallId)
If Len(DisplayName) <> 0 Then
ListIncomingCall.AddItem ("CLI: " DisplayName)
Else
ListIncomingCall.AddItem ("CLI: " UserName)
End If
End If
If ListIncomingCall.ListIndex = -1 And ListIncomingCall.ListCount > 0 Then
ListIncomingCall.ListIndex = 0
End If
End Sub
Private Sub VaxSIPUserAgentOCX_OnIncomingCallRingingStart(ByVal CallId As String)
If CheckPlayRingTone.Value = 1 Then
Retval = PlaySound(ByVal "ring.wav", 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
End If
End Sub
Private Sub VaxSIPUserAgentOCX_OnIncomingCallRingingStop(ByVal CallId As String)
RemoveCallIdFromList (CallId)
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
End Sub
Private Sub VaxSIPUserAgentOCX_OnPlayWaveDone(ByVal LineNo As Long)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Play wave done.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnProvisionalResponse(ByVal LineNo As Long, ByVal StatusCode As Long, ByVal ReasonPhrase As String)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Response: " ReasonPhrase)
End Sub
Private Sub VaxSIPUserAgentOCX_OnRedirectionResponse(ByVal LineNo As Long, ByVal StatusCode As Long, ByVal ReasonPhrase As String, ByVal Contact As String)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Response: " ReasonPhrase)
End Sub
Private Sub VaxSIPUserAgentOCX_OnRequestFailureResponse(ByVal LineNo As Long, ByVal StatusCode As Long, ByVal ReasonPhrase As String)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Response: " ReasonPhrase)
End Sub
Private Sub VaxSIPUserAgentOCX_OnServerFailureResponse(ByVal LineNo As Long, ByVal StatusCode As Long, ByVal ReasonPhrase As String)
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Response: " ReasonPhrase)
End Sub
Private Sub VaxSIPUserAgentOCX_OnSuccessToConnect(ByVal LineNo As Long, ByVal ToRTPIP As String, ByVal ToRTPPort As Long)
If LineNo <> ListLines.ListIndex Then
VaxSIPUserAgentOCX.HoldLine (LineNo)
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : HOLD"
Else
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : BUSY"
End If
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Success to connect.")
Result = VaxSIPUserAgentOCX.GetSpkVolume()
SliderSpkVol.Value = Result / 25
Result = VaxSIPUserAgentOCX.GetMicVolume()
SliderMicVol.Value = Result / 25
Result = VaxSIPUserAgentOCX.IsMicBoostEnable()
If Result = True Then
CheckMicBoost.Value = 1
Else
CheckMicBoost.Value = 0
End If
End Sub
Private Sub VaxSIPUserAgentOCX_OnSuccessToRegister()
AddToStatusLog ("Registered successfully.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnTryingToRegister()
AddToStatusLog ("Trying to register.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnTryingToUnRegister()
AddToStatusLog ("Trying to Unregister.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnSuccessToUnRegister()
AddToStatusLog ("Unregistered successfully.")
End Sub
Private Sub VaxSIPUserAgentOCX_OnFailToUnRegister()
AddToStatusLog ("Fail to unregister.")
End Sub
Private Sub BtnDial_Click()
Dim ToURI
Dim Result
If EditPhoneNo.Text = "" Then
MsgBox ("Please enter a phone number.")
Exit Sub
End If
'*******************************************************
' Constructing SIP To URI for IP Telephony:
' sip:PhoneNumber@SIP Proxy
'********************************************************
ToURI = "sip:" EditPhoneNo.Text "@" EditSIPProxy.Text
LineNo = FindLine()
If LineNo = -1 Then
MsgBox ("No line is free")
Exit Sub
End If
Result = VaxSIPUserAgentOCX.Connect(LineNo, ToURI, ComboAudioIn.ListIndex - 1, ComboAudioOut.ListIndex - 1)
If Result = False Then
ErrorMessages
Else
AddToStatusLog ("Line-" Trim(Str(LineNo 1)) ": Dialing.")
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : CONNECTING"
End If
End Sub
Private Sub BtnHangUp_Click()
Dim Result
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.Disconnect(LineNo)
If Result = False Then
ErrorMessages
End If
End Sub
Private Sub RemoveCallIdFromList(ByVal CallId As String)
For ListIndex = 0 To (ListIncomingCallIds.ListCount - 1)
If UCase(ListIncomingCallIds.List(ListIndex)) = UCase(CallId) Then
ListIncomingCall.RemoveItem (ListIndex)
ListIncomingCallIds.RemoveItem (ListIndex)
ListIndex = ListIndex - 1
End If
Next ListIndex
End Sub
Private Sub BtnAccept_Click()
SelectedItemIndex = ListIncomingCall.ListIndex
If SelectedItemIndex = -1 Then
Exit Sub
End If
LineNo = FindLine()
If LineNo = -1 Then
MsgBox ("No line is free")
Exit Sub
End If
CallId = ListIncomingCallIds.List(SelectedItemIndex)
Result = VaxSIPUserAgentOCX.AcceptCall(LineNo, CallId, ComboAudioIn.ListIndex - 1, ComboAudioOut.ListIndex - 1)
If Result = False Then
ErrorMessages
Exit Sub
End If
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
RemoveCallIdFromList (CallId)
If ListIncomingCall.ListIndex = -1 And ListIncomingCall.ListCount > 0 Then
ListIncomingCall.ListIndex = 0
End If
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : CONNECTING"
End Sub
Private Sub BtnReject_Click()
SelectedItemIndex = ListIncomingCall.ListIndex
If SelectedItemIndex = -1 Then
Exit Sub
End If
CallId = ListIncomingCallIds.List(SelectedItemIndex)
Result = VaxSIPUserAgentOCX.RejectCall(CallId)
If Result = False Then
ErrorMessages
Exit Sub
End If
Retval = PlaySound(ByVal 0&, 0&, SND_ASYNC Or SND_FILENAME Or SND_LOOP Or SND_NODEFAULT)
RemoveCallIdFromList (CallId)
If ListIncomingCall.ListIndex = -1 And ListIncomingCall.ListCount > 0 Then
ListIncomingCall.ListIndex = 0
End If
End Sub
Private Sub BtnResetRecordingBuffer_Click()
LineNo = ListLines.ListIndex
VaxSIPUserAgentOCX.ResetRecording (LineNo)
End Sub
Private Sub BtnSaveToWaveFile_Click()
Dim Result
LineNo = ListLines.ListIndex
Result = VaxSIPUserAgentOCX.SaveRecordingToWaveFile(LineNo, EditSaveFileName.Text)
If Result = False Then
ErrorMessages
Exit Sub
End If
MsgBox ("Saved Successfully")
End Sub
Private Sub ChkStartRecording_Click()
Dim Result
LineNo = ListLines.ListIndex
If ChkStartRecording.Value = 1 Then
Result = VaxSIPUserAgentOCX.StartRecording(LineNo, 2)
Else
Result = VaxSIPUserAgentOCX.StopRecording(LineNo)
End If
End Sub
Private Sub CheckEchoCancel_Click()
If CheckEchoCancel.Value = 1 Then
VaxSIPUserAgentOCX.EnableEchoNoiseCancellation
Else
VaxSIPUserAgentOCX.DisableEchoNoiseCancellation
End If
End Sub
Private Sub CheckMicBoost_Click()
If CheckMicBoost.Value = 1 Then
VaxSIPUserAgentOCX.EnableMicBoost
Else
VaxSIPUserAgentOCX.DisableMicBoost
End If
End Sub
Private Sub CheckDisturb_Click()
If CheckDisturb.Value = 1 Then
VaxSIPUserAgentOCX.EnableDonotDisturb
Else
VaxSIPUserAgentOCX.DisableDonotDisturb
End If
End Sub
Private Sub CheckGSM610_Click()
'****Codec No 0 represents GSM 6.10 *****
If CheckGSM610.Value = 1 Then
VaxSIPUserAgentOCX.SelectVoiceCodec (0)
Else
VaxSIPUserAgentOCX.DeselectVoiceCodec (0)
End If
End Sub
Private Sub CheckiLBC_Click()
'****Codec No 1 represents iLBC *****
If CheckiLBC.Value = 1 Then
VaxSIPUserAgentOCX.SelectVoiceCodec (1)
Else
VaxSIPUserAgentOCX.DeselectVoiceCodec (1)
End If
End Sub
Private Sub CheckG711A_Click()
'****Codec No 2 represents G711 A-LAW *****
If CheckG711A.Value = 1 Then
VaxSIPUserAgentOCX.SelectVoiceCodec (2)
Else
VaxSIPUserAgentOCX.DeselectVoiceCodec (2)
End If
End Sub
Private Sub CheckG711U_Click()
'****Codec No 3 represents G711 U-LAW *****
If CheckG711U.Value = 1 Then
VaxSIPUserAgentOCX.SelectVoiceCodec (3)
Else
VaxSIPUserAgentOCX.DeselectVoiceCodec (3)
End If
End Sub
Private Sub UpdateSoundDevices()
ComboAudioIn.Clear
ComboAudioIn.AddItem ("Default Device")
For DeviceId = 0 To VaxSIPUserAgentOCX.GetAudioInDevTotal() - 1
ComboAudioIn.AddItem (VaxSIPUserAgentOCX.GetAudioInDevName(DeviceId))
Next DeviceId
ComboAudioIn.ListIndex = 0
ComboAudioOut.Clear
ComboAudioOut.AddItem ("Default Device")
For DeviceId = 0 To VaxSIPUserAgentOCX.GetAudioOutDevTotal() - 1
ComboAudioOut.AddItem (VaxSIPUserAgentOCX.GetAudioOutDevName(DeviceId))
Next DeviceId
ComboAudioOut.ListIndex = 0
End Sub
Private Function FindLine() As Integer
LineNo = ListLines.ListIndex
If VaxSIPUserAgentOCX.IsLineBusy(LineNo) = False Then
FindLine = LineNo
Exit Function
End If
For LineNo = 0 To 6
If VaxSIPUserAgentOCX.IsLineBusy(LineNo) = False Then
FindLine = LineNo
Exit Function
End If
Next LineNo
FindLine = -1
End Function
Private Sub TimerProgressBar_Timer()
SpkProgress.Value = VaxSIPUserAgentOCX.GetSpkSoundLevel()
MicProgress.Value = VaxSIPUserAgentOCX.GetMicSoundLevel()
End Sub
Private Sub AddToStatusLog(ByVal StatusLog As String)
ListStatusLog.AddItem (StatusLog)
ListStatusLog.TopIndex = ListStatusLog.ListCount - 1
End Sub
Private Sub UpdateListLine(LineNo As Integer)
If CheckStartConf.Value Then
For LineCount = 0 To 6
If VaxSIPUserAgentOCX.IsLineHold(LineCount) Then
VaxSIPUserAgentOCX.UnHoldLine (LineCount)
End If
Next LineCount
Else
For LineCount = 0 To 6
If LineCount <> LineNo Then
If ((VaxSIPUserAgentOCX.IsLineBusy(LineCount) = True) And (VaxSIPUserAgentOCX.IsLineHold(LineCount) = False)) Then
VaxSIPUserAgentOCX.HoldLine (LineCount)
End If
End If
Next LineCount
If VaxSIPUserAgentOCX.IsLineHold(LineNo) Then
VaxSIPUserAgentOCX.UnHoldLine (LineNo)
End If
End If
End Sub
Private Sub TimerTick_Timer()
If ListLines.ListCount = 0 Then
For LineNo = 0 To 6
ListLines.AddItem ("Line-" Trim(Str(LineNo 1)) " : FREE")
Next LineNo
ListLines.ListIndex = 0
End If
UpdateListLine (ListLines.ListIndex)
If (VaxSIPUserAgentOCX.IsRecording(ListLines.ListIndex) = True) <> (CheckStartRecording.Value = 1) Then
If VaxSIPUserAgentOCX.IsRecording(ListLines.ListIndex) Then
CheckStartRecording.Value = 1
Else
CheckStartRecording.Value = 0
End If
End If
For LineNo = 0 To 6
ItemText = ListLines.List(LineNo)
If VaxSIPUserAgentOCX.IsLineOpen(LineNo) = False Then
If InStr(ItemText, "CLOSE") = 0 Then
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : CLOSE"
End If
Else
If VaxSIPUserAgentOCX.IsLineBusy(LineNo) = True Then
If VaxSIPUserAgentOCX.IsWaveFilePlaying(LineNo) = True Then
If InStr(ItemText, "PLAYING") = 0 Then
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : PLAYING"
End If
Else
If VaxSIPUserAgentOCX.IsLineHold(LineNo) = True Then
If InStr(ItemText, "HOLD") = 0 Then
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : HOLD"
End If
Else
If (InStr(ItemText, "BUSY") = 0) And (InStr(ItemText, "CONNECTING") = 0) Then
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : BUSY"
End If
End If
End If
Else
If InStr(ItemText, "FREE") = 0 Then
ListLines.List(LineNo) = "Line-" Trim(Str(LineNo 1)) " : FREE"
End If
End If
End If
Next LineNo
End Sub
评论